package com.terrace.db.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.terrace.db.constant.DBType;
import com.terrace.db.system.dao.DictDao;
import com.terrace.db.system.mapper.entity.Dict;
import com.terrace.db.system.service.DictService;
import com.terrace.core.mybatis.entity.Pagination;
import com.terrace.core.mybatis.plugin.pagination.PaginationHelper;
import com.terrace.core.spring.datasource.annotation.DataSource;

@Service
@Transactional
@DataSource(name = DBType.ADMIN)
public class DictServiceImpl implements DictService {
	
	@Autowired
	private DictDao dictDao;
	
	@Override
	public int saveDictSelective(Dict dict) {
		return dictDao.saveDictSelective(dict);
	}
	
	@Override
	public int deleteByDictId(String dictId) {
		return dictDao.deleteByDictId(dictId);
	}

	@Override
	public int updateByDictIdSelective(Dict dict) {
		return dictDao.updateByDictIdSelective(dict);
	}

	@Override
	public Dict selectDictById(String dictId) {
		return dictDao.selectDictById(dictId);
	}
	
	@Override
	public Dict selectDictByCode(String dictCode) {
		return dictDao.selectDictByCode(dictCode);
	}
	
	@Override
	public Pagination<Dict> selectDictBySelective(Dict dict, Pagination<Dict> pagination) {
		PaginationHelper.prepare(pagination);
		return PaginationHelper.execute(dictDao.selectDictBySelective(dict));
	}

}
